package demoMod.invincibleOne.patches;

import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.rewards.RewardItem;
import com.megacrit.cardcrawl.screens.CombatRewardScreen;
import demoMod.invincibleOne.interfaces.AddRewardToCombatScreenHook;

import java.util.stream.Collectors;

public class CombatRewardScreenPatch {
    @SpirePatch(
            clz = CombatRewardScreen.class,
            method = "setupItemReward"
    )
    public static class PatchSetupItemReward {
        public static void Postfix(CombatRewardScreen screen) {
            for (AddRewardToCombatScreenHook hook : AbstractDungeon.player.masterDeck.group.stream()
                    .filter(c -> c instanceof AddRewardToCombatScreenHook)
                    .map(c -> (AddRewardToCombatScreenHook) c)
                    .collect(Collectors.toList())) {
                for (RewardItem item : screen.rewards) {
                    hook.onAddRewardToCombatRewardScreen(item);
                }
            }
        }
    }
}
